package graphics.raytracing;

import static util.MatrixOperationsF.*;
import graphics.datastructures.Triangle;
import drawing.DrawingEngine;

public class CameraDependendWindow implements Window<Triangle> {
	private Window<Triangle> window;
	public CameraDependendWindow(CameraPosition position,float distance,float h,float v, int xmax, int ymax, LightSource source, DrawingEngine engine, int red, CameraPosition pos)
	{
		float[] o =position.getOrigin();
		float[] direction =position.getDirection();
		float[] up =position.getUp();
		float[] right =cross_product(up, direction);
		up = multiply(up, v);
		right = multiply(right, h);
		float[] center=add(o,multiply(direction, distance));
		float [] lb=add(add(center,negate(right)),negate(up));
		up = multiply(up, 2);
		right=multiply(right, 2);
		window=new SimpleWindowWithCallback(center, right, up, xmax, ymax, source, engine, red, pos);
	}
	public Ray determineRay(int x, int y) {
		return window.determineRay(x, y);
	}
	public float[] getColor(int x, int y) {
		return window.getColor(x, y);
	}
	public void color(int i, int j, float[] color) {
		window.color(i, j, color);
	}
	public int[] xy() {
		return window.xy();
	}
	public float[][][] getView() {
		return window.getView();
	}
	public void waitForSet() {
		window.waitForSet();
	}
	public float[] getCenter() {
		return window.getCenter();
	}
	public void reset() {
		window.reset();
	}
	@Override
	public void setShader(Shader s) {
		window.setShader(s);
	}

	@Override
	public void color(int[] _xy, CastResult<Triangle> result) {
		window.color(_xy, result);
	}
	@Override
	public Shader getShader() {
		return window.getShader();
	}

}
